package com.ruoyi.web.controller.system.api.cc;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.framework.interceptor.Authentication;
import com.ruoyi.system.api.ResponseWithData;
import com.ruoyi.system.api.domain.FseLocationLog;
import com.ruoyi.system.api.domain.User;
import com.ruoyi.system.api.service.EngineerManageService;
import com.ruoyi.system.api.service.IFseLocationLogService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;

/**
 * @ClassName engineerManage
 * @Description: 工程师管理
 * @Author wlf
 * @Date 2020/3/3
 * @Version V1.0
 **/
@Api(tags="工程师管理")
@Controller
@RequestMapping("/api/cc/engineerManage")
public class EngineerManageController extends BaseController {

    @Autowired
    EngineerManageService engineerManageService;

    @Autowired
    IFseLocationLogService locationLogService;

    private static final Logger log = LoggerFactory.getLogger(EngineerManageController.class);
    /**
     * team下fse查询(可能与实时查询调用相同接口)
     * @methodName: selectTlEngineer
     * @description: TODO
     * @param teamleaderId
     * @return: com.ruoyi.system.api.ResponseWithData<?>
     * @author: wlf
     * @date: 2020/3/9 11:09
     **/
    @PostMapping("/selectTlEngineer")
    @ResponseBody
    @Authentication(tokenRequired = true, signRequired = true)
    @ApiOperation(value = "team下fse查询", httpMethod = "POST", notes = "team下fse查询")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "TL主键ID",name="teamleaderId",required = true,dataType="String",example="TL主键ID")
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "code 为 500 系统异常"),
            @ApiResponse(code = 200, message = "code 为 200 成功")
    })
    public ResponseWithData<?> selectTlEngineer(@RequestBody String teamleaderId){
        try {
            return engineerManageService.selectTlEngineer(teamleaderId);
        }catch (Exception e){
            log.error("程序异常", e.getMessage());
            return new ResponseWithData().error().msg("系统异常").code(500);
        }
    }

    /**
     * fse历史轨迹查询
     * @methodName: getFseLocation
     * @description: TODO
     * @param locationLog
     * @return: com.ruoyi.system.api.ResponseWithData<?>
     * @author: wlf
     * @date: 2020/3/9 11:09
     **/
    @PostMapping("/getFseLocation")
    @ResponseBody
    @Authentication(tokenRequired = true, signRequired = true)
    @ApiOperation(value = "获取FSE历史轨迹接口", httpMethod = "POST", notes = "获取FSE历史轨迹接口")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "fse主键ID", name = "fseId", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(value = "开始时间", name = "startTime", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(value = "结束时间", name = "endTime", required = true, dataType = "String", paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "code 为 500 系统异常"),
            @ApiResponse(code = 200, message = "code 为 200 成功" )
    })
    public ResponseWithData<?> getFseLocation(@RequestBody FseLocationLog locationLog){
        try {
            return locationLogService.getFseLocationLog(locationLog);
        }catch (Exception e){
            log.error("程序异常", e.getMessage());
            return new ResponseWithData().error().msg("系统异常").code(500);
        }
    }

    /**
     * 异常fse
     * @methodName: getErrorFse
     * @description: TODO
     * @param params
     * @return: com.ruoyi.system.api.ResponseWithData<?>
     * @author: wlf
     * @date: 2020/3/9 11:09
     **/
    @PostMapping (value = "/getErrorFse")
    @ResponseBody
    @Authentication(tokenRequired = true, signRequired = true)
    @ApiOperation(value = "获取异常fse接口", httpMethod = "POST", notes = "获取异常fse接口")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "TL主键ID",name="teamleaderId",required = true,dataType="String",example="TL主键ID")
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "code 为 500 系统异常"),
            @ApiResponse(code = 200, message = "code 为 200 成功")
    })
    public ResponseWithData<?> getErrorFse(@RequestBody Map<String, String> params){
        try {
            return locationLogService.getErrorFse(params);
        }catch (Exception e){
            log.error("程序异常", e.getMessage());
            return new ResponseWithData().error().msg("系统异常").code(500);
        }
    }

    /**
     * 查询本地team下fse（没走CC端）
     * @methodName: selectTlEngineer
     * @description: TODO
     * @param params
     * @return: com.ruoyi.system.api.ResponseWithData<?>
     * @author: wlf
     * @date: 2020/4/9 19:53
     **/
    @PostMapping("/selectTeamFseLocal")
    @ResponseBody
    @Authentication(tokenRequired = true, signRequired = true)
    @ApiOperation(value = "team下fse查询", httpMethod = "POST", notes = "team下fse查询")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "TL主键ID",name="teamleaderId",required = true,dataType="String",example="TL主键ID"),
            @ApiImplicitParam(value = "FSE名称",name="enginnerName",required = false,dataType="String",example="FSE名称")
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "code 为 500 系统异常"),
            @ApiResponse(code = 200, message = "code 为 200 成功")
    })
    public ResponseWithData<?> selectTeamFseLocal(@RequestBody Map<String, String> params){
        try {
            return locationLogService.selectTeamFseLocal(params);
        }catch (Exception e){
            log.error("程序异常", e.getMessage());
            return new ResponseWithData().error().msg("系统异常").code(500);
        }
    }
    /**
     * 查询本地team下fse以及所有的fse
     * @methodName: selectTlEngineer
     * @description: TODO
     * @param params
     * @return: com.ruoyi.system.api.ResponseWithData<?>
     * @author: wlf
     * @date: 2020/4/9 19:53
     **/
    @PostMapping("/selectTransferFse")
    @ResponseBody
    @Authentication(tokenRequired = true, signRequired = true)
    @ApiOperation(value = "team下fse查询", httpMethod = "POST", notes = "team下fse查询")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "FSEId",name="enginnerId",required = true,dataType="String",example="FSE主键"),
            @ApiImplicitParam(value = "FSE名称",name="enginnerName",required = false,dataType="String",example="FSE名称")
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "code 为 500 系统异常"),
            @ApiResponse(code = 200, message = "code 为 200 成功")
    })
    public ResponseWithData<?> selectTransferFse(@RequestBody Map<String, String> params){
        try {
            return locationLogService.selectTransferFse(params);
        }catch (Exception e){
            log.error("程序异常", e.getMessage());
            return new ResponseWithData().error().msg("系统异常").code(500);
        }
    }
    /**
     * 历史轨迹fse下拉内容
     * @methodName: selectFseByTlid
     * @description: TODO
     * @param params
     * @return: com.ruoyi.system.api.ResponseWithData<?>
     * @author: wlf
     * @date: 2020/4/24 14:27
     **/
    @PostMapping("/selectFseByTlid")
    @ResponseBody
    @Authentication(tokenRequired = true, signRequired = true)
    @ApiOperation(value = "历史轨迹fse下拉内容", httpMethod = "POST", notes = "历史轨迹fse下拉内容")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "TL主键ID",name="teamleaderId",required = true,dataType="String",example="TL主键ID")
    })
    @ApiResponses({
            @ApiResponse(code = 500, message = "code 为 500 系统异常"),
            @ApiResponse(code = 200, message = "code 为 200 成功")
    })
    public ResponseWithData<?> selectFseByTlid(@RequestBody Map<String, String> params){
        try {
            return locationLogService.selectFseByTlid(params);
        }catch (Exception e){
            log.error("程序异常", e.getMessage());
            return new ResponseWithData().error().msg("系统异常").code(500);
        }
    }

}
